<div class="layuimini-main">
    <div class="layui-form layuimini-form">
        <div class="layui-form-item">
            <label class="layui-form-label required">原密码</label>
            <div class="layui-input-block">
                <input type="password" name="spassword" lay-verify="required" lay-reqtext="原密码不能为空" placeholder="请输入原密码" value="" class="layui-input">
                <tip>输入原密码</tip>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label required">新密码</label>
            <div class="layui-input-block">
                <input type="password" name="npassword" lay-verify="required" lay-reqtext="新密码不能为空" placeholder="请输入新密码" class="layui-input">
                <tip>输入新密码</tip>
            </div>
        </div>

      <div class="layui-form-item">
        <label class="layui-form-label required">确认新密码</label>
        <div class="layui-input-block">
          <input type="password" name="dpassword" lay-verify="required|npassword" lay-reqtext="确认新密码不能为空" placeholder="请输入确认新密码" class="layui-input">
          <tip>输入确认新密码</tip>
        </div>
      </div>

        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn layui-btn-normal" lay-submit lay-filter="saveBtn">确认保存</button>
            </div>
        </div>
    </div>
</div>
<script>
    layui.use(['form', 'table','axios','ztree'], function () {
        let form = layui.form,
            layer = layui.layer,
            ztree = layui.ztree,
            axios = layui.axios,
            $ = layui.$;

          //当前弹出层，防止ID被覆盖
          let parentIndex = layer.index;

          //监听提交
          form.on('submit(saveBtn)', function (data) {
              axios.post('user/pwd',data.field).then(function(response){
                  if(response.code == 200){
                      layer.msg(response.msg);
                  }
                  layer.close(parentIndex);
              }).catch(function (error) {
                  layer.msg(error);
              });
              return false;
          });

    });
</script>